<%@ page language="java" import="java.util.*, java.text.*,com.zjut.zs.util.tools.*,com.zjut.an.util.tools.*,com.zjut.an.util.system.*,
com.zjut.zs.user.manager.*, com.zjut.zs.user.dao.*,com.zjut.zs.userstatus.manager.*, com.zjut.zs.userstatus.dao.*,com.zjut.zs.applyview.manager.*, com.zjut.zs.applyview.dao.*,
com.zjut.zs.userinfo.manager.*, com.zjut.zs.userinfo.dao.*,com.zjut.an.config.manager.*, com.zjut.an.config.dao.*,
com.zjut.zs.exampage.manager.*, com.zjut.zs.exampage.dao.*,com.zjut.zs.school.manager.*, com.zjut.zs.school.dao.*" pageEncoding="utf-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">  
<meta name="renderer" content="webkit"> 
<title></title>

<link href="../plugins/assets/plugins/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css"/>
<script src='../plugins/assets/plugins/jquery-3.5.1.min.js'></script>
<script src="js/jquery.qrcode-0.6.0.min.js"></script>
<script src="js/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript">
function printHtml(html) {
	var bodyHtml = document.body.innerHTML;
	document.body.innerHTML = html;
	window.print();
	document.body.innerHTML = bodyHtml;
}
function onprint() {
	var html = $("#container").html();
	printHtml(html);
}
</script>
</head>
<style type="text/css">
ul{display:block;margin:0;padding:0;list-style:none;}
li{display:block;margin:0;padding:0;list-style: none;}
.place{height:40px; background:url(images/righttop.gif) repeat-x;}
.place span{line-height:40px; font-weight:bold;float:left; margin-left:12px;}
.placeul li{float:left; line-height:40px; padding-left:7px; padding-right:12px; background:url(images/rlist.gif) no-repeat right;}
.placeul li:last-child{background:none;}

</style>
<body>
<jsp:include page="zs_uservalidate.jsp" flush="true"/>
<%
if (session.getAttribute("zsUser") == null&&session.getAttribute("admin") == null&&session.getAttribute("user") == null) {
	out.print("<script>alert('由于长时间未操作，系统已经自动注销，请重新登陆');</script>");
	out.print("<script>top.window.location='main.jsp';</script>");
} else {

AnConfigManager anconfig = (AnConfigManager) SpringContextUtil.getBean("AnConfigManager");
ZsHTMLCreat html = (ZsHTMLCreat) SpringContextUtil.getBean("ZsHTMLCreat");
ZsSchoolManager zsManager = (ZsSchoolManager) SpringContextUtil.getBean("ZsSchoolManager");
ZsUserStatusManager usmanager = (ZsUserStatusManager) SpringContextUtil.getBean("ZsUserStatusManager");
ZsUserinfoManager uimanager = (ZsUserinfoManager) SpringContextUtil.getBean("ZsUserinfoManager");
ZsUserManager umanager = (ZsUserManager) SpringContextUtil.getBean("ZsUserManager");
ZsExamPageManager epmanager = (ZsExamPageManager) SpringContextUtil.getBean("ZsExamPageManager");
ZsApplyViewManager amanager = (ZsApplyViewManager) SpringContextUtil.getBean("ZsApplyViewManager");
ZsSchool school = new ZsSchool();
school = (ZsSchool)zsManager.getDataByInstance(1,1,null,null,school).getObjects().get(0);

ZsUser user = null;
if(session.getAttribute("admin")!=null && request.getParameter("usId")!=null) {
	String usId = request.getParameter("usId");
	user = umanager.getData(usId);
} else if (session.getAttribute("zsUser")!=null) {
	user = umanager.getData(((ZsUser)session.getAttribute("zsUser")).getUsId());
} 

ZsUserinfo userinfo = new ZsUserinfo();
ZsExamPage exampage = new ZsExamPage();

ZsUserStatus userstatus = new ZsUserStatus();
if (user!=null) {
	userinfo.setZsUser(user);
	userinfo = (ZsUserinfo)uimanager.getDataByInstance(1,1,null,null,userinfo).getObjects().get(0);
	
	userstatus.setZsUser(user);
	userstatus = (ZsUserStatus)usmanager.getDataByInstance(1,1,null,null,userstatus).getObjects().get(0);
	if (null != userstatus.getExId()) {
		exampage = epmanager.getData(userstatus.getExId());
	}
}

//String receiveno = user.getUsNo();

ZsApplyView appview = amanager.getData(user.getUsId());

 %>
	<div class="place" style="margin-top:0;">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="index.jsp">首页</a></li>
    <li><a href="#"><%=anconfig.getSingleConfigInfoByName("准考证名称") %></a></li>
    </ul>
    </div>
    
    <%if (session.getAttribute("admin") != null) {//准考证单独打印模块
    	%>
    	<div id="custom-toolbar">
		<%if (Status.LOCALSTATUS_YES.getStatus().equals(userstatus.getLocalStatus())){ %>
	    	<a href="#" class="btn default disabled bbtn">已经面试签到</a>
	    <%} else { %>
	    	<button class="btn btn-primary btn-sm"  onclick="#" id="demo_3">确认面试签到</button>
	    <%} %>	    
	    </div>
    	<%
    	if ("do".equals(request.getParameter("action")) && null!=userstatus.getZsUser()) {//尚未编号才能再次编号
    		userstatus.setExId(Integer.parseInt(request.getParameter("exId")));
    		exampage = epmanager.getData(Integer.parseInt(request.getParameter("exId")));
    		if(null==userstatus.getTestNo() || userstatus.getTestNo().trim().length()==0) {
	    		
	    		//******生成专业顺序号******//
	    		//ZsApplyView topview = new ZsApplyView();
				//topview.setColumn1(appview.getColumn1());
				//topview.setTestNo("0");
				//List topviewlist = amanager.getDataByInstance(1,10000,"testNo", "asc", topview).getObjects();
	    		//int testNoOrder = topviewlist.size()+1;
	    		//System.out.println("现有专业报名次序号："+topviewlist.size());
		    	//userinfo.setInSg(String.valueOf(testNoOrder));//保存顺序号。
		    	//uimanager.updateData(userinfo);
		    	
		    	//usmanager.getTestNoOrder(user);
		    	usmanager.updateData(userstatus);
	    		usmanager.getTestNo(userstatus);//生成准考证编号并保存
    		}	
    		
    	}    
    %>
    <form id="ff" name="add" role="form" class="form-horizontal" action="zs_examprint.jsp" method="post" style="display:none;"> 
	<div class="form-group">  
	<ul class="forminfo">
		<li class="clear"><label>准考证打印<b>*</b></label></li>
		<% 
			ZsExamPage expages = new ZsExamPage();
			expages.setExType("准考证");
			
			List list = epmanager.getDataByInstance(1,100,null,null,expages).getObjects();
			for (int i=0; i<list.size(); i++){
				expages = (ZsExamPage)list.get(i);
			 %>							 
				<li>
				<input type="radio" name="exId" id="exId" value="<%=expages.getExId() %>" checked> 
				<%=expages.getExTitle() %>
				</li>						 
			<%} %>
		<li class="clear"><label>&nbsp;</label>
		<input id="usId" name="usId" type="text" class="dfinput" value="<%=user.getUsId() %>"  style="display:none;"/>
		<input id="action" name="action" type="text" class="dfinput" value="do"  style="display:none;"/>
		<button type="submit" class="btn btn-primary btn-sm">生成准考证</button>
		</li>
		<li class="clear"><label>&nbsp;</label>当前准考证尚未编号才能进行单独编号，单独编号从目前已编号中取最大加1。已经编号不能再次编号。</li>
	</ul>
    </div>
    </form>
    <%} %>
    <div class="xline"></div>
    <input type="button" onclick="onprint()" value="打印" class="btn btn-primary btn-sm" style="margin:20px;"/>
    <div id="container" class="container" style="width:1000px;">
   
    <%
    if (null!=exampage.getExId()) {
    	String content = exampage.getExContent().replace("$usName$", appview.getUsName())
    	.replace("$usIdcard$", html.getInputString(appview.getUsIdcard()))
    	.replace("$usEmail$", html.getInputString(appview.getUsEmail()))
    	.replace("$usMobile$", html.getInputString(appview.getUsMobile()))
    	.replace("$testNo$", html.getInputString(appview.getTestNo()))
    	.replace("$column1$", html.getInputString(appview.getColumn1()))
    	.replace("$column2$", html.getInputString(appview.getColumn2()))
    	.replace("$column3$", html.getInputString(appview.getColumn3()))
    	.replace("$column4$", html.getInputString(appview.getColumn4()))
    	.replace("$column5$", html.getInputString(appview.getColumn5()))
    	.replace("$column6$", html.getInputString(appview.getColumn6()))
    	.replace("$column7$", html.getInputString(appview.getColumn7()))
    	.replace("$column8$", html.getInputString(appview.getColumn8()))
    	.replace("$column9$", html.getInputString(appview.getColumn9()))
    	.replace("$column10$", html.getInputString(appview.getColumn10()))
    	.replace("$inZydm01$", html.getInputString(appview.getInZydm01()))
    	.replace("$inZydm02$", html.getInputString(appview.getInZydm02()))
    	.replace("$inZydm03$", html.getInputString(appview.getInZydm03()))
    	.replace("$inZydm04$", html.getInputString(appview.getInZydm04()))
    	.replace("$inZydm05$", html.getInputString(appview.getInZydm05()))
    	.replace("$inZydm06$", html.getInputString(appview.getInZydm06()))
    	.replace("$inZydm07$", html.getInputString(appview.getInZydm07()))
    	.replace("$inZydm08$", html.getInputString(appview.getInZydm08()))
    	.replace("$inZydm09$", html.getInputString(appview.getInZydm09()))
    	.replace("$inZydm10$", html.getInputString(appview.getInZydm10()))
    	.replace("$inZymc01$", html.getInputString(appview.getInZymc01()))
    	.replace("$inZymc02$", html.getInputString(appview.getInZymc02()))
    	.replace("$inZymc03$", html.getInputString(appview.getInZymc03()))
    	.replace("$inZymc04$", html.getInputString(appview.getInZymc04()))
    	.replace("$inZymc05$", html.getInputString(appview.getInZymc05()))
    	.replace("$inZymc06$", html.getInputString(appview.getInZymc06()))
    	.replace("$inZymc07$", html.getInputString(appview.getInZymc07()))
    	.replace("$inZymc08$", html.getInputString(appview.getInZymc08()))
    	.replace("$inZymc09$", html.getInputString(appview.getInZymc09()))
    	.replace("$inZymc10$", html.getInputString(appview.getInZymc10()))
    	.replace("$scColumn1$", html.getInputString(appview.getScColumn1()))
    	.replace("$scColumn2$", html.getInputString(appview.getScColumn2()))
    	.replace("$scColumn3$", html.getInputString(appview.getScColumn3()))
    	.replace("$scColumn4$", html.getInputString(appview.getScColumn4()))
    	.replace("$scColumn5$", html.getInputString(appview.getScColumn5()))
    	.replace("$scColumn6$", html.getInputString(appview.getScColumn6()))
    	.replace("$scColumn7$", html.getInputString(appview.getScColumn7()))
    	.replace("$scColumn8$", html.getInputString(appview.getScColumn8()))
    	.replace("$scColumn9$", html.getInputString(appview.getScColumn9()))
    	.replace("$scColumn10$", html.getInputString(appview.getScColumn10()))
    	.replace("$inXb$", html.getInputString(appview.getInXb()))
    	.replace("$inMz$", html.getInputString(appview.getInMz()))
    	.replace("$inZzmm$", html.getInputString(appview.getInZzmm()))
    	.replace("$usBmxh$", html.getInputString(appview.getUsBmxh())) 
    	.replace("$inKslb$", html.getInputString(appview.getInKslb()))
    	.replace("$inLxdh$", html.getInputString(appview.getInLxdh()))
    	.replace("$inLxdh2$", html.getInputString(appview.getInLxdh2()))
    	.replace("$inByxxmc$", html.getInputString(appview.getInByxxmc()))
    	.replace("$testNoOrder$", html.getInputString(appview.getInPinying()))
    	.replace("$inXxbz1$", html.getInputString(appview.getInXxbz1()))
    	.replace("$inXxbz2$", html.getInputString(appview.getInXxbz2()))
    	.replace("$inXxbz3$", html.getInputString(appview.getInXxbz3()))
    	.replace("$receiveno$", user.getUsNo());
    	content = content.replace("src=\"inPhoto\"", "src='../photo/"+html.getInputString(user.getUsIdcard())+".jpg' ");   	
	    out.print(content);
    } else {
    	out.print("尚未分配准考证");
    }
    %>
	</div>
<script>
$("#ewcode1").attr("src","https://sapi.k780.com/?app=qr.get&data=<%=anconfig.getSingleConfigInfoByName("网站域名") %>/admin/zsApplyViewStatus.jsp?usId=<%=user.getUsId()%>&level=L&size=6&localStatusType=single"); 
$("#ewcode2").attr("src","https://sapi.k780.com/?app=qr.get&data=<%=anconfig.getSingleConfigInfoByName("网站域名") %>/admin/zsApplyViewEdit.jsp?usId=<%=user.getUsId()%>&level=L&size=6"); 



function localStatus(){
	$.ajax({
	    cache: false,
	    type: "POST",
	    url:'../zsUserStatusLocal.action?localStatusType=single&ussId=<%=userstatus.getUssId()%>',
	    dataType:"html",
	    async: false,
	    error: function(request) {
	    	alert("设置签到有误");
	    },
	    success: function(data) {///成功跳转
	    	location.reload(true);
        }
	});
}
$('#demo_3').click(function(){
	if(window.confirm('确认进行面试签到吗?')){
        localStatus();  
    }else{
	
    }
});
</script>

<%} %>
</body>
</html>
